<?php

namespace App\Repositories\Eloquent\Biz;

use App\Repositories\Eloquent\Repository;

class TrackRepository extends Repository
{

    function model()
    {
        return 'App\Models\Biz\Track';
    }


    public function set($user, $activity, $type)
    {
        $this->create([
            'aid'       => $activity->id,
            'uid'       => $user->id,
            'account'   => $user->account,
            'type'      => $type,
            'date'      => time(),
        ]);

    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index($query = '')
    {
        // 获取分页数据
        if (!$query) {
            $result = $this->model
                ->orderBy('order', 'asc');
        } else {
            // 若有查询参数
            $result = $this->model
                ->where('name', 'like', "%$query%");
        }

        return $result;
    }


    
}